<?php
/**
 * 订单管理
 */
namespace Admin\Controller;
import('SoeLib.UHCore',WEB_ROOT);
use Admin\BaseController;
use Think\Page;
class OrderController extends BaseController{
	
	/*根据父级ID获得权限节点列表*/
	public function index(){
		//$this->smarty->assign('lastModifyDateTime',$lastModifyTime);
		//$this->smarty->assign('page',$show);
		//$this->smarty->assign('list',$list);
		$this->smarty->assign('action','index');
		$this->smarty->display('Order/index.html');
	}

	/**
	 *　重新获取优盒的订单数据
	 * Author: shijy
	 */
	public function refreshUHOrder(){
		import('ThirdLib.Snoopy',WEB_ROOT);
		$result=\UHCore::queryOrderInfo();
		if($result[0]==SUCCESS) {
			$this->log('成功');
			$this->success("数据获取成功");
		}else{
			$this->error("数据获取失败");
			$this->log('失败');
		}
	}

	//显示优盒订单界面
	public function order(){
		$orderM = M("uh_order",null,DB_MAIN_CFG);
		import("ORG.Util.Page");
		$count = $orderM->count();
		$Page = new Page($count,10);
		$show = $Page->show(); // 分页显示输出
		$list = $orderM	->limit($Page->firstRow.','.$Page->listRows)->select();


		$refreshM=M('update_config_log',null,DB_MAIN_CFG);
		$opt=\UHCore::QUERY_ORDER_INFO;
		$lastModifyTime=$refreshM->where("action='{$opt}'")->getField('addTime');
		$lastModifyTime=$lastModifyTime?getDateTime($lastModifyTime):"从未刷新";
		$this->smarty->assign('lastModifyDateTime',$lastModifyTime);

		$this->smarty->assign('page',$show);
		$this->smarty->assign('list',$list);
		$this->smarty->assign('action','order');
		$this->smarty->display('Order/order.html');
	}

	//本平台订单
	public function localOrder(){
		$orderM = M("u_order",null,DB_MAIN_CFG);
		import("ORG.Util.Page");
		$count = $orderM->count();
		$Page = new Page($count,10);
		$show = $Page->show(); // 分页显示输出
		$list = $orderM	->limit($Page->firstRow.','.$Page->listRows)->select();


		$this->smarty->assign('page',$show);
		$this->smarty->assign('list',$list);
		$this->smarty->assign('action','localOrder');
		$this->smarty->display('Order/localOrder.html');
	}
}
